﻿; (function () {

    'use strict';
    window.SaveManager = {

        init: function () {

        },

        tryLoadItem: function (key, type) {
            var inst = localStorage.getItem(key);
            if (inst) {
                try {

                    inst = ObjectSerializer.deserializeRoot(inst);
                    if (inst instanceof type) {
                        return inst;
                    }
                    else {
                        localStorage.removeItem(key);
                    }

                } catch (e) {
                    console.log(e);
                    localStorage.removeItem(key);
                }
            }
            return null;
        },

        saveItem: function (key, inst) {
            localStorage.setItem(key, ObjectSerializer.serialize(inst));
        },

        removeItem: function (key) {
            localStorage.removeItem(key);
        }
    };

    window.SaveManager.init();

}());
